﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1.Mobile
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string title = Request.QueryString["title"];
            string mTag = Request.QueryString["mTag"];
            string music = Request.QueryString["music"];
            string college = Request.QueryString["college"];
            string insp = Request.QueryString["insp"];
            string sports = Request.QueryString["sports"];
            if (title != null && title != "")
            {
                if (dsmTunez.SelectParameters.Contains(dsmTunez.SelectParameters["title"]) == false)
                {
                    dsmTunez.SelectParameters.Add("title", System.Data.DbType.String, title.Trim());
                }
                dsmTunez.SelectCommand = "SELECT * FROM [tabmTunez] WHERE ([title] LIKE '%' + @title + '%') ORDER BY [date] DESC";
            }
            else if (mTag != null && mTag != "")
            {
                if (dsmTunez.SelectParameters.Contains(dsmTunez.SelectParameters["mainTag"]) == false)
                {
                    dsmTunez.SelectParameters.Add("mainTag", System.Data.DbType.String, mTag.Trim());
                }
                dsmTunez.SelectCommand = "SELECT * FROM [tabmTunez] WHERE ([mainTag] LIKE '%' + @mainTag + '%') ORDER BY [date] DESC";
            }
            else
                dsmTunez.SelectCommand = "SELECT * FROM [tabmTunez] ORDER BY [date] DESC";


        }
        protected string getrtsp(string vid, int hd)
        {
            //0 -- SD
            //1 -- HD
            try
            {

                string[] str = new string[2];
                Vid3 obj = new Vid3();
                str = obj.rtspURL(vid).Split(','); ;
                return str[hd];
            }
            catch
            {
                return "NA";
            }
        }
        protected string details(string vid, int i)
        {
            //0 -- rating
            //1 -- viewcount  
            //2 -- duration
            //3 -- published
            //4 -- imagepath

            // try
            //  {
            Vid3 obj = new Vid3();
            string[] str = new string[10];
            str = obj.Rating(vid);
            double dec = Convert.ToDouble(str[0].Substring(2, 1));
            if (dec > 7)
                dec = 1.0;
            else if (dec > 3)
                dec = 0.5;
            else
                dec = 0.0;
            dec += Convert.ToDouble(str[0].Substring(0, 1));

            string path = "Images/stars/stars_" + String.Format("{0:0.0}", dec) + "_49x9.gif";
            dec = 0;
            str[4] = path;
            return str[i];
            //    }
            //    catch
            //    {
            //       return "NA";
            //   }

        }

    }

}